<template>
  <a-spin :spinning="confirmLoading" style="background: #fff">
    <j-form-container :disabled="false">
      <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
        <a-row :gutter="48">
          <a-col :span="8" :hidden="true">
            <a-form-model-item label="流程名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="bpmBizTitle" >
              <a-input :max-length="255" :disabled="formDisabled1" v-model="model.bpmBizTitle" placeholder="请输入流程名称"></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="单据编号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="htbh">
              <a-input :disabled="true" v-model="model.htbh" placeholder="请输入单据编号"></a-input>
            </a-form-model-item>
          </a-col>

          <a-col :span="8">
            <a-form-model-item label="申请时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="createTime">
              <j-date :disabled="true" placeholder="请选择申请时间" v-model="model.createTime" style="width: 100%"/>
            </a-form-model-item>
          </a-col>

          <a-col :span="8">
            <a-form-model-item label="申请人" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="proposer">
              <select-user-by-dep disabled :multi="false" v-model="model.proposer"/>
            </a-form-model-item>
          </a-col>

          <a-col :span="8">
            <a-form-model-item label="申请部门" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="proposerDeptId">
              <j-select-depart :disabled="true" v-model="model.proposerDeptId"/>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="申请人所属团队" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="applyTeam">
              <select-team-input
                :disabled="formDisabled1"
                v-model="model.applyTeam"
                :tdlx="1"/>
            </a-form-model-item>
          </a-col>
        </a-row>
          <!-- <a-divider>基本信息</a-divider> -->
        <a-collapse v-model="activeKey">
          <a-collapse-panel key="1" header="基本信息">
            <a-row :gutter="48">
              <template v-if="sfbg">
                <a-col :span="8">
                  <a-form-model-item label="合同编号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="caId">
                    <select-contract-manager-input
                      :muitFlag = "true"
                      :disabled="formDisabled1"
                      v-model="model.caId"
                      :allList="true"
                      :status="'2'"
                      @change="htbhChange"
                      :triggerChange="true"/>
                  </a-form-model-item>
                </a-col>
              </template>
              <a-col :span="8">
                <a-form-model-item label="合同名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="htmc">
                  <a-input :disabled="formDisabled" v-model="model.htmc" placeholder="请输入合同名称"></a-input>
                </a-form-model-item>
              </a-col>
              <!--16.7新增的字段 ；流程中编辑时禁用-->
              <a-col :span="8" v-if="model.htlx == '2'">
                <a-form-model-item label="费用类型" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="feeType">
                  <j-dict-select-tag  type="list" v-model="model.feeType"
                                      dictCode="fee_type"
                                      placeholder="请选择费用类型" disabled/>
                </a-form-model-item>
              </a-col>
              <a-col :span="8" v-if="model.htlx == '2'">
                <a-form-model-item label="是否采购类" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="isCategoryType">
                  <j-dict-select-tag
                    :disabled="formDisabled"
                    type="radio"
                    v-model="model.isCategoryType"
                    dictCode="is_category_type"
                    @input="handleChangeCategory"
                    placeholder="请选择是否采购类"/>
                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <a-form-model-item label="合同类型" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="htlx">
                  <j-dict-select-tag
                    disabled
                    type="list"
                    v-model="model.htlx"
                    dictCode="htlx_type"
                    placeholder="请选择合同类型"
                    @change="htlxChange"
                    :triggerChange="true"/>
                </a-form-model-item>
              </a-col>

              <template v-if="sfbg">
                <a-col :span="8">
                  <a-form-model-item label="变更类型" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="bglx">
                    <j-dict-select-tag
                      :disabled="formDisabled1"
                      type="list"
                      v-model="model.bglx"
                      dictCode="pay_contract_change_type"
                      placeholder="请选择变更类型"/>
                  </a-form-model-item>
                </a-col>
              </template>

              <a-col :span="8">
                <a-form-model-item label="项目名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="xmmc">
                  <a-input :readOnly="true" v-model="model.xmmc_dictText"  style="color: #1890FF;"   @click.prevent="getProjectDetail(model.xmmc)"></a-input>
                </a-form-model-item>
              </a-col>
              <a-col :span="8"  v-show = "model.isCategoryType == '1'">
                <a-form-model-item label="采购类型" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="provisionType">
                  <j-dict-select-tag @input="handleChangeProvisionType" type="list" dictCode="provision_type" :disabled="formDisabled"  v-model="model.provisionType" placeholder="请选择采购类型" />
                </a-form-model-item>
              </a-col>
              <a-col :span="8" v-show = "model.provisionType == '1'" >
                <a-form-model-item label="关联单据" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="calibrationId">
                  <a-input v-if="formDisabled" readOnly @click.prevent="goPurchaseCalibrationDetail(model)"  v-model="model.calibrationNo" style="color: #1890FF; cursor: pointer;"  placeholder="请关联定标结果确认单"></a-input>
                  <select-purchase-calibration-input v-else :disabled="formDisabled" placeholder="请关联定标结果确认单" v-model="model.calibrationId" :projectId="model.xmmc"  />
                </a-form-model-item>
              </a-col>
              <a-col :span="8" v-show = "model.provisionType == '2'" >
                <a-form-model-item label="关联单据" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="purchaseApplyId">
                  <a-input v-if="formDisabled" readOnly @click.prevent="goPurchaseApplyDetail(model)"  v-model="model.purchaseNo" style="color: #1890FF; cursor: pointer;"  placeholder="请关联采购申请单"></a-input>
                  <select-purchase-apply-form-contract-input v-else :disabled="formDisabled" placeholder="请关联采购申请单" v-model="model.purchaseApplyId"  />
                </a-form-model-item>
              </a-col>
              <a-col :span="8" v-show = "model.provisionType == '3'" >
                <a-form-model-item label="关联单据" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="invitationId">
                  <a-input v-if="formDisabled" readOnly @click.prevent="goInvitationDetail(model)"  v-model="model.invitationNo" style="color: #1890FF; cursor: pointer;"  placeholder="请关联采购申请单"></a-input>
                  <SelectPurchasingRequisitionInput v-else  v-model="model.invitationId" placeholder="请关联招标采购申请单"  :disabled="formDisabled" />
                </a-form-model-item>
              </a-col>
              <a-col :span="8" style="display:none">
                <a-form-model-item label="项目编号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="xmbh">
                  <a-input :disabled="true" v-model="model.xmbh" placeholder="请输入项目编号"></a-input>
                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <!-- 迭代16.7 选择经营费用的时候，单据中经营团队改成费用所属团队，弹窗团队选择； -->
                <a-form-model-item v-if="model.htlx == '2' && model.feeType=='2'" label="费用所属团队" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="jytd">
                  <select-team-input
                    @back="changeVal"
                    :disabled="formDisabled1"
                    v-model="model.jytd"
                    :tdlx="1"/>
                </a-form-model-item>
                <a-form-model-item v-else label="经营团队" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="jytd">
                  <select-team-input
                    @back="changeVal"
                    :disabled="formDisabled"
                    v-model="model.jytd"
                    :tdlx="1"/>
                </a-form-model-item>
              </a-col>
              <!-- <a-col :span="8"> 
              <a-form-model-item  label="经营公司" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="businessCompanyId">
              <select-Company-input :disabled="formDisabled" placeholder="请选择经营公司" v-model="model.businessCompanyId" disabled />
            </a-form-model-item>
            </a-col> -->
              <a-col :span="8">
                <a-form-model-item label="业绩归属年度" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="yjgsnd">
                  <j-dict-select-tag
                    :disabled="formDisabled"
                    type="list"
                    v-model="model.yjgsnd"
                    dictCode="yjgsnd"
                    placeholder="请选择业绩归属年度"/>
                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <a-form-model-item label="签订单位" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="qddw">
                  <select-Company-input :disabled="formDisabled1" v-model="model.qddw" placeholder="请选择签订单位"/>
                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <a-form-model-item label="项目承接人" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="xmcjr">
                  <select-user-by-dep :disabled="formDisabled1" :multi="false" v-model="model.xmcjr"/>
                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <a-form-model-item label="业主单位" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="yzdw">
                  <!-- <select-customer-input
                    :disabled="formDisabled"
                    v-model="model.yzdw"
                    :commercialType="model.htlx"
                    @change="yzdwChange"/> -->
                    <!--迭代11 6.若合同类型为付款合同，业主单位改为取供应商改为待定-->
                  <select-customer-input
                  :disabled="formDisabled"
                  v-model="model.yzdw"
                  commercialType="1"
                  @change="yzdwChange"/>
                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <a-form-model-item label="联系人" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="lxr">
                  <j-dict-select-tag
                    :disabled="formDisabled"
                    type="list"
                    v-model="model.lxr"
                    :dictCode="cust_lxr"
                    placeholder="请选择联系人"
                    @change="lxrChange"
                    :triggerChange="true"/>
                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <a-form-model-item label="联系方式" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="lxfs">
                  <a-input :disabled="formDisabled" v-model="model.lxfs" placeholder="请输入联系方式"></a-input>
                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <a-form-model-item label="签订日期" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="qdrq">
                  <j-date :disabled="formDisabled" placeholder="请选择签订日期" v-model="model.qdrq" style="width: 100%"/>
                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <a-form-model-item label="履约保证金（元）" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="bail">
                  <a-input-number :disabled=formDisabled :max="99999999" :min="0" :precision="2" v-model="model.bail" placeholder="请输入履约保证金"  style="width: 100%" />
                </a-form-model-item>
              </a-col>
              <a-col v-if="model.feeType === '1'" :span="8">
                <a-form-model-item label="任务编号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="taskId">
                  <SelectTaskFileInput
                    disabled
                    v-model="model.taskId"
                  />
                </a-form-model-item>
              </a-col>
              <a-col :span="8" v-show="model.htlx==1">
                <a-form-model-item
                  label="分配方式"
                  :labelCol="labelCol"
                  :wrapperCol="wrapperCol"
                  prop="distributionMethod">
                    <j-dict-select-tag
                      disabled
                      type="list"
                      v-model="model.distributionMethod"
                      @change="changeMoney"
                      dictCode="distribution_method"
                      placeholder="请选择分配方式"/>

                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <!-- 迭代11 1.是否用章改为是否用印，变更为必选项，不给默认值 -->
                <a-form-model-item label="是否用印" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="sfyz">
                  <j-dict-select-tag
                    :disabled="formDisabled"
                    type="radio"
                    v-model="model.sfyz"
                    dictCode="yn"
                    @input="handleChangeSeal"
                    placeholder="请选择是否用印"/>
                </a-form-model-item>
              </a-col>
              <a-col :span="8" v-if="isShowSeal">
                <a-form-model-item label="用印类型" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="signSealWay">
                  <j-dict-select-tag
                    :disabled="formDisabled"
                    type="select"
                    v-model="model.signSealWay"
                    dictCode="seal_way"
                    @input="handleChangeSignSealWay"
                    placeholder="请选择用印类型"/>
                </a-form-model-item>
              </a-col>
              <a-col :span="8" v-if="isShowSeal">
                <a-form-model-item label="印章类型" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="yzlx">
                  <j-multi-select-tag
                    :disabled="formDisabled"
                    type="select"
                    v-model="model.yzlx"
                    dictCode="yzlx_type"
                    placeholder="请选择印章类型"/>
                </a-form-model-item>
              </a-col>
              <a-col :span="8" v-if="isShowSeal">
                <a-form-model-item label="用印份数" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="yyfs">
                  <a-input-number
                    :disabled="formDisabled"
                    :max="99999999"
                    :min="0"
                    v-model="model.yyfs"
                    placeholder="请输入用印份数"
                    style="width: 100%"/>
                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <!--迭代16.8 增加是否存档字段 流程中不可编辑-->
                <a-form-model-item label="是否存档" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="sfcd">
                  <j-dict-select-tag
                    type="radio"
                    v-model="model.sfcd"
                    dictCode="yes_no"
                    placeholder="请选择是否存档"/>
                </a-form-model-item>
              </a-col>
              <a-col :span="8" v-if="model.sfcd==='1'">
                <!--迭代16.8 增加是否存档字段 流程中不可编辑-->
                <a-form-model-item label="合同存档份数" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="cdfs">
                  <a-input-number :max="99999999" :min="0" v-model="model.cdfs"
                                  placeholder="请输入合同存档份数" style="width: 100%"/>
                </a-form-model-item>
              </a-col>
              <template v-if="!isShowSeal">
                <a-col :span="12">
                  <a-form-model-item label="合同原件" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="masterCopy">
                    <j-upload v-if="model.sfyz == 1" :disabled="formDisabled" v-model="model.masterCopy"></j-upload>
                    <a-button v-else icon="download" @click="viewFile(model.masterCopy)">文件列表</a-button>
                  </a-form-model-item>
                </a-col>
              </template>
              <a-col :span="8" :hidden="model.htlx == '1'">
                <a-form-model-item label="关联收款合同" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="glskht">
                  <j-dict-select-tag
                    :disabled="isFkht ? false : true"
                    type="radio"
                    v-model="model.glskht"
                    dictCode="yn"
                    placeholder="请选择关联收款合同"
                    @change="glskhtChange"
                    :triggerChange="true"/>
                </a-form-model-item>
              </a-col>
              <template v-if="glhtFlag">
                <a-col :span="8">
                  <a-form-model-item label="收款合同名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="skhtmc">
                    <select-contract-manager-input
                      :muitFlag = "true"
                      v-model="model.skhtmc"
                      htlx="1"
                      @back="skhtBack"
                      :allList="true"
                      :triggerChange="true"/>
                  </a-form-model-item>
                </a-col>
                <a-col :span="8">
                  <a-form-model-item label="收款合同额(元)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="skhte">
                    <a-input-number
                      disabled
                      :max="99999999"
                      :min="0"
                      v-model="model.skhte"
                      placeholder="请输入收款合同额"
                      style="width: 100%"
                      @blur="convertMoney1"/>
                  </a-form-model-item>
                </a-col>
                <a-col :span="8">
                  <a-form-model-item label="收款合同额大写" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="skhtedx">
                    <a-input disabled v-model="model.skhtedx" placeholder="请输入收款合同额大写"></a-input>
                  </a-form-model-item>
                </a-col>
              </template>
              <a-col :span="8">
                <a-form-model-item label="本次合同额(元)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="bchte">
                  <a-input-number
                    :precision="2"
                    :max="99999999"
                    :min="0"
                    v-model="model.bchte"
                    placeholder="请输入本次合同额"
                    style="width: 100%"
                    @change="convertMoney2"/>
                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <a-form-model-item label="本次合同额大写" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="bchtedx">
                  <a-input :disabled="true" v-model="model.bchtedx" placeholder="请输入本次合同额大写"></a-input>
                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <a-form-model-item label="服务期限" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="fwqx">
                  <!-- <j-date placeholder="请选择服务期限" v-model="model.fwqx" style="width: 100%"/> -->
                  <a-range-picker
                  :disabled="formDisabled"
                  :allowClear="false"
                  v-model="createTime"
                  style="width: 100%"
                  @change="createTimeChange"/>
                </a-form-model-item>
              </a-col>
            </a-row>
          </a-collapse-panel>
          <a-collapse-panel key="2" :header="this.firstTitle">
            <a-row :gutter="48">
              <!-- <a-divider style="top:20px;">{{ this.firstTitle }}</a-divider> -->
              <a-col :span="24">
                <div style="margin-bottom: 6px;margin-top: 6px">
                  <a-button @click="handleAdd4" v-if="!formDisabled" type="primary">新增</a-button>
                </div>
                <a-table
                  ref="table"
                  size="middle"
                  rowKey="id"
                  :loading="loading"
                  :columns="columns4"
                  :pagination="false"
                  :data-source="dataSource4">
                  <span slot="action" slot-scope="text, record">
                    <template v-if="!formDisabled">
                      <a @click="handleEdit4(record)">编辑</a>
                      <a-divider type="vertical"/>
                      <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete4(record.id)">
                        <a>删除</a>
                      </a-popconfirm>
                    </template>
                  </span>
                </a-table>
              </a-col>
            </a-row>
          </a-collapse-panel>
          <a-collapse-panel key="3" :header="this.secondTitle">
            <a-row :gutter="48">
              <!-- <a-divider style="top:20px;">{{ this.secondTitle }}</a-divider> -->
              <a-col :span="24">
                <div style="margin-bottom: 6px;margin-top: 6px">
                  <a-button @click="handleAdd3" v-if="!formDisabled" type="primary">新增</a-button>
                </div>
                <a-table
                  ref="table"
                  size="middle"
                  rowKey="id"
                  :loading="loading"
                  :columns="columns3"
                  :pagination="false"
                  :data-source="dataSource3">
                  <span slot="action" slot-scope="text, record">
                    <template v-if="!formDisabled">
                      <a @click="handleEdit3(record)">编辑</a>
                      <a-divider type="vertical"/>
                      <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete3(record.id)">
                        <a>删除</a>
                      </a-popconfirm>
                    </template>
                  </span>
                </a-table>
              </a-col>
            </a-row>
          </a-collapse-panel>
          <template  v-if="this.model.htlx == '1'">
            <a-collapse-panel key="4" header="任务信息">
              <a-row :gutter="48">
                <!-- <template  v-if="this.model.htlx == '1'"> -->
                <!-- <a-divider style="top:20px;">任务信息</a-divider> -->
                <a-col :span="24">
                  <j-vxe-table
                    ref="vTable"
                    row-number
                    keep-source
                    height="auto"
                    :loading="loading"
                    :dataSource="dataSource2"
                    :columns="columns2"
                    style="margin-top: 8px;"
                    @valueChange="handleValueChange"
                  >
                    <template #htzb="{ row,rowIndex }">
                      <a-input-number @change="handleJvxeChange($event,rowIndex,'htzb')" :disabled='model.distributionMethod==2' :max="99999999" :min="0" :precision="2" v-model="row.htzb" style="width: 100%" />
                    </template>
                    <template #fphte="{ row,rowIndex }">
                      <a-input-number @change="handleJvxeChange($event,rowIndex,'fphte')" :disabled='model.distributionMethod==1' :max="99999999" :min="0" :precision="2" v-model="row.fphte" style="width: 100%" />
                    </template>
                  </j-vxe-table>
                </a-col>
              </a-row>
            </a-collapse-panel>
          </template>
          <a-collapse-panel key="5" header="收付款计划">
            <a-row :gutter="48">
              <!-- <a-divider style="top:20px;">收付款计划</a-divider> -->
              <template v-if="sfbg">
                <a-col :span="8">
                  <a-form-model-item label="是否变更款项信息" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="sfbgkxxx">
                    <j-dict-select-tag
                      :disabled="formDisabled"
                      type="radio"
                      v-model="model.sfbgkxxx"
                      dictCode="yn"
                      :triggerChange="true"
                      @change="handleChangeSfbgkxxx"
                      placeholder="请选择是否变更款项信息"/>
                  </a-form-model-item>
                </a-col>
              </template>
              <a-col :span="24" >
                <div style="margin-bottom: 6px;margin-top: 6px" v-if="showKxxx">
                  <a-button @click="handleAdd" v-if="!formDisabled" type="primary">新增</a-button>
                </div>
                <a-table
                  ref="table"
                  size="middle"
                  rowKey="id"
                  :loading="loading"
                  :columns="columns"
                  :pagination="false"
                  bordered
                  :scroll="{x:scrollXOther}"
                  :components="draggableComponentOther"
                  :data-source="dataSource">
                  <span slot="action" slot-scope="text, record">
                    <template v-if="!formDisabled && showKxxx">
                      <a @click="handleEdit(record)">编辑</a>
                      <span v-if="sfbg && !record.finalId ">
                        <a-divider type="vertical"/>
                        <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                          <a >删除</a>
                        </a-popconfirm>
                      </span>
                    </template>
                  </span>
                </a-table>
              </a-col>
            </a-row>
          </a-collapse-panel>
          <a-collapse-panel key="6" header="其他信息">
            <a-row :gutter="48">
              <a-col :span="24">
                <a-form-model-item label="备注" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="bz">
                  <a-textarea :maxLength="500" :disabled="formDisabled" v-model="model.bz" rows="4" placeholder="请输入备注"/>
                </a-form-model-item>
              </a-col>
              <a-col :span="24">
                <a-form-model-item label="邮寄信息" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="yjxx">
                  <a-textarea :maxLength="500" :disabled="formDisabled" v-model="model.yjxx" rows="4" placeholder="请输入邮寄信息"/>
                </a-form-model-item>
              </a-col>
            </a-row>
          </a-collapse-panel>
          <a-collapse-panel key="7" header="合同原件扫描件">
            <a-row :gutter="48">
              <a-col :span="24">
                <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="contractOrgFile">
                  <template v-slot:label>
                    <span >合同原件扫描件</span><span style="color: #faad14;font-weight: 600">（仅合同管理员上传！）</span>
                  </template>
                  <j-upload v-if="!formDisabled" :disabled="formDisabled" fileFormat=".pdf, .PDF, .doc, .docx" fileFormatText="请上传word与pdf格式的文件！" v-model="model.contractOrgFile"></j-upload>
                  <a-button v-else icon="download" @click="viewFile(model.contractOrgFile)">文件列表</a-button>
                </a-form-model-item>
              </a-col>
            </a-row>
          </a-collapse-panel>
          <a-collapse-panel key="8" header="用印文件" v-if="model.sfyz == 1">
            <a-row :gutter="48">
              <a-col :span="24">
                <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="signFile">
                  <template v-slot:label>
                    <span >用印文件</span><span style="color: #faad14;font-weight: 600">（请上传只需盖章的用印文件！）</span>
                  </template>
                  <a-button icon="download" @click="viewFile(model.signFile)">文件列表</a-button>
                </a-form-model-item>
              </a-col>
            </a-row>
          </a-collapse-panel>
          <a-collapse-panel key="9" header="相关附件">
            <a-row :gutter="48">
              <a-col :span="24">
                <a-form-model-item label="" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="xgfj">
                  <j-upload v-if="!formDisabled" :disabled="formDisabled" v-model="model.xgfj"></j-upload>
                  <a-button v-else icon="download" @click="viewFile(model.xgfj)">文件列表</a-button>
                </a-form-model-item>
              </a-col>
            </a-row>
          </a-collapse-panel>
        </a-collapse>
      </a-form-model>
      <common-flow-list v-if="formBpm && model.bpmStatus !== '1'" :formData="formData" style="margin-top: 10px"></common-flow-list>
      <view-file-modal ref="viewFileModal"></view-file-modal>
      <!--收付款计划-->
      <erp-omc-pay-contract-manager-plan-modal :htlx="model.htlx" :bchte="remainBchte" ref="itemList" @ok="modalFormOk"></erp-omc-pay-contract-manager-plan-modal>
      <erp-omc-contract-manager-class-modal ref="itemList2" @ok="modalFormOk2"></erp-omc-contract-manager-class-modal>
      <erp-omc-contract-manager-trustee-modal
        :htlx="model.htlx"
        :signSealWay="model.signSealWay"
        ref="itemList3"
        @ok="modalFormOk3"></erp-omc-contract-manager-trustee-modal>
      <erp-omc-contract-manager-entrust-modal
        :htlx="model.htlx"
        :signSealWay="model.signSealWay"
        ref="itemList4"
        @ok="modalFormOk4"></erp-omc-contract-manager-entrust-modal>
      <!-- 项目详情开始 -->
      <erp-project-report-modal  ref="reportForm"></erp-project-report-modal>
    </j-form-container> 
    <a-row :gutter="48">
      <a-col :span="24" style="text-align: center;margin-top: 15px">
        <a-button type="primary" v-if="formBpm" :style="{ marginRight: showFlowSubmitButton?'10px':'0px' }" @click="onPrint">打印</a-button>
        <a-button @click="submitForm('submit')" v-if="showFlowSubmitButton">提 交</a-button>
      </a-col>
    </a-row>

    <ErpOmcPayContractManagerEditForm_backPrint v-if="formBpm && isSubmit" class="print_style" id="payContractmanageContent1" :formData="model1" :formDataHistory="formData"></ErpOmcPayContractManagerEditForm_backPrint>

    <ErpPurchaseCalibrationBillPenetrate ref="purchaseCalibrationBillPenetrate" ></ErpPurchaseCalibrationBillPenetrate>

    <ErpPurchaseApplyFormPenetrate ref="purchaseApplyFormPenetrate" ></ErpPurchaseApplyFormPenetrate>
    <ErpPurchaseApplyInvitationPenetrate ref="purchaseInvitationFormPenetrate" ></ErpPurchaseApplyInvitationPenetrate>
  </a-spin>
</template>

<script>
import { getAction, httpAction } from '@/api/manage'
import { viewFile } from '@/utils/util'
import SelectProjectInput from '@/views/scy/components/SelectProjectInput'
import SelectTeamInput from '@/views/scy/components/SelectTeamInput'
import SelectUserByDep from '@/views/scy/components/SelectUserByDep'
import SelectCustomerInput from '@/views/scy/components/SelectCustomerInput'
import SelectContractInput from '@/views/scy/components/SelectContractInput'
import { convertCurrency } from '@/utils/MoneyConvert'
import ViewFileModal from '@/views/scy/components/ViewFileModal'
import ErpOmcPayContractManagerPlanModal from '../modules/ErpOmcPayContractManagerPlanModal'
import ErpOmcContractManagerClassModal from '../modules/ErpOmcContractManagerClassModal'
import ErpOmcContractManagerTrusteeModal from '../modules/ErpOmcContractManagerTrusteeModal'
import ErpOmcContractManagerEntrustModal from '../modules/ErpOmcContractManagerEntrustModal'
import { filterMultiDictText, initDictOptions } from '@/components/dict/JDictSelectUtil'
import SelectContractManagerInput from '@/views/scy/components/SelectContractManagerInput'
import moment from 'moment';
import { mapGetters } from 'vuex';
import { message } from 'ant-design-vue'
import SelectCompanyInput from '@/views/scy/components/SelectCompanyInput'
import { JVXETypes } from '@/components/jeecg/JVxeTable'
import {filterDictTextByCache} from '@/components/dict/JDictSelectUtil'
import SelectPurchaseCalibrationInput from '@/views/scy/components/SelectPurchaseCalibrationInput'
import CommonFlowList from '@/views/components/CommonFlowList.vue';
import ErpProjectReportModal from '@/views/erp/report/project/modules/ErpProjectReportModal'
import SelectPurchaseApplyFormContractInput from '@/views/scy/components/SelectPurchaseApplyFormContractInput'
import Print from '@/utils/print/printarea.js';
import ErpOmcPayContractManagerEditForm_backPrint from './ErpOmcPayContractManagerEditForm_backPrint' // 打印
import SelectTaskFileInput from '@/views/scy/components/SelectTaskFileInput'; //  任务编号
import SelectPurchasingRequisitionInput from '@/views/scy/components/SelectPurchasingRequisitionInput'
import ErpPurchaseCalibrationBillPenetrate from '@/views/scy/penetrate/ErpPurchaseCalibrationBillPenetrate'
import ErpPurchaseApplyFormPenetrate from '@/views/scy/penetrate/ErpPurchaseApplyFormPenetrate'
import ErpPurchaseApplyInvitationPenetrate from '@/views/scy/penetrate/ErpPurchaseApplyInvitationPenetrate'
import { DragResizable } from '@/mixins/DragResizable'

export default {
  name: 'ErpOmcPayContractManagerEditFormBack',
  mixins: [viewFile,DragResizable],
  components: { // select-customer-input
    SelectPurchaseApplyFormContractInput,
    ErpProjectReportModal,
    SelectTaskFileInput,
    SelectPurchaseCalibrationInput,
    SelectProjectInput,
    SelectTeamInput,
    SelectUserByDep,
    SelectCustomerInput,
    SelectContractInput,
    ViewFileModal,
    ErpOmcPayContractManagerPlanModal,
    ErpOmcContractManagerClassModal,
    ErpOmcContractManagerTrusteeModal,
    ErpOmcContractManagerEntrustModal,
    SelectContractManagerInput,
    SelectCompanyInput,
    CommonFlowList,
    ErpOmcPayContractManagerEditForm_backPrint,
    SelectPurchasingRequisitionInput,
    ErpPurchaseCalibrationBillPenetrate,
    ErpPurchaseApplyFormPenetrate,
    ErpPurchaseApplyInvitationPenetrate
  },
  props: {
    // 流程表单data
    formData: {
      type: Object,
      default: () => {
      },
      required: false
    },
    // 表单模式：true流程表单 false普通表单
    formBpm: {
      type: Boolean,
      default: false,
      required: false
    },
    // 表单禁用
    disabled: {
      type: Boolean,
      default: false,
      required: false
    }
  },
  data() {
    return {
      activeKey: ['1', '2', '3', '4', '5', '6', '7', '8', '9'],
      isSubmit: true,
      model: {
        // 迭代11 1.是否用章改为是否用印，变更为必选项，不给默认值
        // sfyz: 0,
        glskht: 0,
        sfbgkxxx: 0,
        jf: undefined,
        yf: undefined
      },
      model1: { // 打印
        // 迭代11 1.是否用章改为是否用印，变更为必选项，不给默认值
        // sfyz: 0,
        glskht: 0,
        sfbgkxxx: 0,
        jf: undefined,
        yf: undefined
      },
      labelCol: {},
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 24 }
      },
      confirmLoading: false,
      validatorRules: {
        bchte: [
          { required: true, message: '请输入本次合同额!' }
        ],
        // bpmBizTitle: [
        //   { required: true, message: '请输入流程名称!' },
        // ],
        htlx: [
          { required: true, message: '请输入合同类型!' }
        ],
        htmc: [
          { required: true, message: '请输入合同名称!' }
        ],
        xmmc: [
          { required: true, message: '请输入项目名称!' }
        ],
        jytd: [
          { required: true, message: '请输入经营团队!' }
        ],
        yjgsnd: [
          { required: true, message: '请输入业绩归属年度!' }
        ],
        qddw: [
          { required: true, message: '请输入签订单位!' }
        ],
        xmcjr: [
          { required: true, message: '请输入项目承接人!' }
        ],
        yzdw: [
          { required: true, message: '请输入业主单位!' }
        ],
        qdrq: [
          { required: true, message: '请输入签订日期!' }
        ],
        yzlx: [
          { required: true, message: '请选择印章类型!' }
        ],
        yyfs: [
          { required: true, message: '请填写用印份数!', trigger: 'blur' },
          { pattern: /^[0-9]*[1-9][0-9]*$/, message: '请输入正整数!' }
        ],
        lxfs: [
          { required: false },
          { pattern: /(^1\d{10}$|^(0\d{2,3}-?|\(0\d{2,3}\))?[1-9]\d{4,7}(-\d{1,8})?$)|(^\/$)/, message: '请输入正确的联系方式!' }
        ],
        sfyz: [
          { required: true, message: '请选择是否用印!'  }
        ],
        signSealWay: [
          { required: true, message: '请选择用印类型!' }
        ],
        feeType: [
          { required: true, message: '请选择费用类型!' }
        ],
        bail: [
          { required: true, message: '请输入履约保证金!', trigger: 'blur'},
          // { pattern: /^(0|[1-9]\d*)$/, message: '请输入正确的履约保证金!' }
        ],
        sfcd: [
          { required: true, message: '请选择是否存档!' }
        ],
        cdfs: [
          { required: true, message: '请输入存档份数!' }
        ],
        contractOrgFile: [
          { required: true, message: '请上传合同原件扫描件!' }
        ],
      },
      url: {
        queryProjectReportById: '/api/erp/project/report/erpProjectReport/queryById',
        add: '/api/erp/omc/contractmanager/erpOmcContractManager/add',
        edit: '/api/erp/omc/contractmanager/erpOmcContractManager/edit',
        queryPlanList: '/api/erp/omc/contractmanager/erpOmcContractManagerPlan/listAll',
        queryById: '/api/erp/omc/contractmanager/erpOmcContractManager/queryById',
        queryClassList: '/api/erp/omc/contractmanager/erpOmcContractManagerClass/listAll',
        queryClassList2: '/api/erp/omc/project/erpOmcProjectTask/list',
        queryEntrustList: '/api/erp/omc/contractmanager/erpOmcContractManagerEntrust/listAll',
        queryTrusteeList: '/api/erp/omc/contractmanager/erpOmcContractManagerTrustee/listAll',
        queryProjectDeposit: '/api/erp/finance/deposit/erpFinanceProjectDepositBill/queryByEntity',
        generatedFormNumber: '/api/erp/base/generatedFormNumber',
        queryFinalByHtbh: '/api/erp/omc/contractmanager/erpOmcContractManagerFinal/queryByHtbh',
        //获取定标结果确认单信息
        queryCalibrationById: '/api/erp/purchase/procurement/erpPurchaseCalibration/queryById',
        //获取采购申请单信息
        queryPurchaseApplyById: '/api/erp/purchase/procurement/erpPurchaseApplyForm/queryById',
        //获取招标采购单信息
        queryInvitationById: '/api/erp/purchase/procurement/erpPurchaseApplyInvitation/queryById'
      },
      loading: false,
      columns: [
        {
          title: '款项名称',
          align: 'center',
          width: 188,
          ellipsis: true,
          dataIndex: 'kxmc'
        },
        {
          title: '金额(元)',
          align: 'center',
          width: 188,
          ellipsis: true,
          dataIndex: 'je'
        },
        {
          title: '预计款项日期',
          align: 'center',
          width: 188,
          ellipsis: true,
          dataIndex: 'kxrq'
        },
        {
          title: '款项节点说明',
          align: 'center',
          width: 188,
          ellipsis: true,
          dataIndex: 'kxjdsm'
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: 'center',
          width: 150,
          scopedSlots: {
            filterDropdown: 'filterDropdown',
            filterIcon: 'filterIcon',
            customRender: 'action'
          }
        }
      ],
      columns2: [
        {
          title: '业务编码',
          align: 'center',
          key: 'ywfl',
          formatter: ({ cellValue}) => {
            return cellValue ? filterMultiDictText(this.dictOptions['ywfl'], cellValue + '') : ''
          }
        },
        {
          title: '业务名称',
          align: 'center',
          key: 'ywmc'
        },
        {
          title: '合同占比(%)',
          align: 'center',
          key: 'htzb',
          slotName: 'htzb',
          type: JVXETypes.slot
        },
        {
          title: '分配合同额（元）',
          align: 'center',
          key: 'fphte',
          slotName: 'fphte',
          type: JVXETypes.slot
        },
        {
          title: '生产团队',
          align: 'center',
          key: 'sctd_dictText',
          // formatter: ({ cellValue }) => {
          //   return cellValue ? filterMultiDictText(this.dictOptions['sctd'], cellValue + '') : ''
          // }
        },
        {
          title: '团队负责人',
          align: 'center',
          key: 'tdfzr_dictText',
          // formatter: ({ cellValue }) => {
          //   return cellValue ? filterMultiDictText(this.dictOptions['tdfzr'], cellValue + '') : ''
          // }
        }
      ],
      columns3: [
        {
          title: '名称',
          align: 'center',
          dataIndex: 'gsdaId',
          customRender: (text) => {
            if (!text) {
              return ''
            } else {
              return filterMultiDictText(this.dictOptions['gsda'], text + '')
            }
          }
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: 'center',
          scopedSlots: {
            filterDropdown: 'filterDropdown',
            filterIcon: 'filterIcon',
            customRender: 'action'
          }
        }
      ],
      columns4: [
        {
          title: '名称',
          align: 'center',
          dataIndex: 'khdaId',
          customRender: (text) => {
            if (!text) {
              return ''
            } else {
              return filterMultiDictText(this.dictOptions['khda'], text + '')
            }
          }
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: 'center',
          scopedSlots: {
            filterDropdown: 'filterDropdown',
            filterIcon: 'filterIcon',
            customRender: 'action'
          }
        }
      ],
      createTime: [],// 服务期限
      dataSource: [], // 收付款计划数据源
      dataSource2: [], // 任务信息
      dataSource3: [], // 受托方信息
      dataSource4: [], // 委托方信息
      dictOptions: {},
      // 迭代11 委托方改为委托方(合同甲方)，受托方改为受托方（合同乙方）
      firstTitle: '委托方(合同甲方)信息',
      secondTitle: '受托方(合同乙方)信息',
      cust_lxr: 'erp_omc_customer_manager_contact,lxr,id',
      glhtFlag: false,
      sfbg: false,
      isFkht: false,
      showKxxx: false,
      // 修改时加上当前行的值
      editRemain: 0,
      involveMultipleFlag: false,
      showMasterCopy: false
    }
  },
  computed: {
    formDisabled1() {
        return true
    },
    formDisabled() {
      if (this.formBpm === true) {
        if (this.formData.disabled === false) {
          return false
        }
        return true
      }
      return this.disabled
    },
    showFlowSubmitButton() {
      if (this.formBpm === true) {
        if (this.formData.disabled === false) {
          return true
        }
      }
      return false
    },
    isShowSeal () {
      if (this.model.sfyz && this.model.sfyz == 1) {
        return true
      } else {
        return false
      }
    },
    // 合同额剩余可分配值
    remainBchte() {
      if (this.model.bchte) {
        let remain = this.model.bchte + this.editRemain;
        this.dataSource.forEach(data => {
          remain -= data.je;
        })
        return remain;
      } else {
        return 0;
      }
    }
  },
  created() {
    // 备份model原始值
    this.modelDefault = JSON.parse(JSON.stringify(this.model));
    // 如果是流程中表单，则需要加载流程表单data
    this.showFlowData();
    this.initDictConfig();
    this.otherKey = 'columns'
    this.columnswidth = this.columns.map(val => {
      return val.width
    })
  },
  methods: {
    changeVal(val) {
      this.$set(this.model, 'businessCompanyId',val[0].belongCompanyId)
    },

    getProjectDetail (id) {
      const that = this
      this.$nextTick(() => {
        getAction(this.url.queryProjectReportById, { id }).then((res) => {
          if (res.success) {
            const model = res.result
            that.$refs.reportForm.getDetail(model);
            that.$refs.reportForm.title = '项目一览表';
          }
        })
      })
    },
    goPurchaseCalibrationDetail(record) {
      this.$refs.purchaseCalibrationBillPenetrate.initData(record.calibrationId);
      this.$refs.purchaseCalibrationBillPenetrate.visible = true;
    },
    goPurchaseApplyDetail(record) {
      this.$refs.purchaseApplyFormPenetrate.initData(record.purchaseApplyId);
      this.$refs.purchaseApplyFormPenetrate.visible = true;
    },
    goInvitationDetail(record) {
      this.$refs.purchaseInvitationFormPenetrate.initData(record.invitationId);
      this.$refs.purchaseInvitationFormPenetrate.visible = true;
    },
    initDictConfig() {
      initDictOptions('ywfx_type').then((res) => {
        if (res.success) {
          this.$set(this.dictOptions, 'ywfl', res.result)
        }
      })
      initDictOptions('erp_purchase_supplier,enterprise_name,id').then((res) => {
        if (res.success) {
          this.$set(this.dictOptions, 'khda', res.result)
        }
      })

      initDictOptions('erp_company_files,file_name,id').then((res) => {
        if (res.success) {
          this.$set(this.dictOptions, 'gsda', res.result)
        }
      })
    },
    handleAdd() {
      this.$refs.itemList.add();
      this.$refs.itemList.title = '新增';
      this.$refs.itemList.disableSubmit = false;
      // this.isFkht = false;
      this.isFkht = true;
    },
    handleEdit(record) {
      // 修改时将当前的值从remain中减去
      this.editRemain = record.je;
      this.$refs.itemList.edit(record);
      this.$refs.itemList.title = '修改';
      this.$refs.itemList.disableSubmit = false;
    },
    handleChangeSeal(val) {
      if (val == 0) {
        this.$set(this.validatorRules, 'masterCopy', [{ required: true, message: '请上传合同原件!' }]);
        // 修改子表数据
        if (this.dataSource3 && this.dataSource3.length) {
          this.dataSource3.forEach(value => {
            value.psnName = null
            value.psnMobile = null
            return value
          })
        }
        if (this.dataSource4 && this.dataSource4.length) {
          this.dataSource4.forEach(value => {
            value.isSignSeal = '0'
            value.psnName = null
            value.psnMobile = null
            return value
          })
        }
      } else {
        this.$set(this.model, 'masterCopy', '');
        this.$delete(this.validatorRules, 'masterCopy');
      }
    },
    handleChangeSignSealWay (val) {
      if (val != 'online') {
        if (this.dataSource3 && this.dataSource3.length) {
          this.dataSource3.forEach(value => {
            value.psnName = null
            value.psnMobile = null
            return value
          })
        }
        if (this.dataSource4 && this.dataSource4.length) {
          this.dataSource4.forEach(value => {
            value.isSignSeal = '0'
            value.psnName = null
            value.psnMobile = null
            return value
          })
        }
      } else {
        if (this.dataSource4 && this.dataSource4.length) {
          this.dataSource4.forEach(value => {
            value.isSignSeal = '0'
            value.psnName = null
            value.psnMobile = null
            return value
          })
        }
      }
    },
    handleDelete(id) {
      for (let i = 0; i < this.dataSource.length; i++) {
        if (this.dataSource[i].id == id) {
          this.dataSource.splice(i, 1);
        }
      }
    },
    handleAdd2() {
      this.$refs.itemList2.add();
      this.$refs.itemList2.title = '新增';
      this.$refs.itemList2.disableSubmit = false;
    },
    handleEdit2(record) {
      this.$refs.itemList2.edit(record);
      this.$refs.itemList2.title = '修改';
      this.$refs.itemList2.disableSubmit = false;
    },
    handleDelete2(id) {
      for (let i = 0; i < this.dataSource2.length; i++) {
        if (this.dataSource2[i].id == id) {
          this.dataSource2.splice(i, 1);
        }
      }
    },
    handleAdd3() {
      this.$refs.itemList3.add();
      this.$refs.itemList3.title = '新增';
      this.$refs.itemList3.disableSubmit = false;
    },
    handleEdit3(record) {
      this.$refs.itemList3.edit(record);
      this.$refs.itemList3.title = '修改';
      this.$refs.itemList3.disableSubmit = false;
    },
    handleDelete3(id) {
      for (let i = 0; i < this.dataSource3.length; i++) {
        if (this.dataSource3[i].id == id) {
          this.dataSource3.splice(i, 1);
        }
      }
    },
    handleAdd4() {
      this.$refs.itemList4.add();
      this.$refs.itemList4.title = '新增';
      this.$refs.itemList4.disableSubmit = false;
    },
    handleEdit4(record) {
      this.$refs.itemList4.edit(record);
      this.$refs.itemList4.title = '修改';
      this.$refs.itemList4.disableSubmit = false;
    },
    handleDelete4(id) {
      for (let i = 0; i < this.dataSource4.length; i++) {
        if (this.dataSource4[i].id == id) {
          this.dataSource4.splice(i, 1);
        }
      }
    },
    modalFormOk(data) {
      this.loading = true;
      let flag = true;
      // debugger;
      for (let i = 0; i < this.dataSource.length; i++) {
        if (this.dataSource[i].id == data.id) {
          this.dataSource.splice(i, 1, data);
          flag = false;
        }
      }
      if (flag) {
        this.dataSource.push(data);
      }
      this.loading = false;
    },
    modalFormOk2(data) {
      if (!data.ywmc) return false // 如果没有填写数据
      this.loading = true;
      let flag = true;
      // debugger;
      for (let i = 0; i < this.dataSource2.length; i++) {
        if (this.dataSource2[i].ywfl == data.ywfl) {
          this.dataSource2.splice(i, 1, data);
          flag = false;

        }
      }
      if (flag) {
        this.dataSource2.push(data);
      }
      this.loading = false;
    },
    modalFormOk3(data) {
      this.loading = true;
      let flag = true;
      // debugger;
      for (let i = 0; i < this.dataSource3.length; i++) {
        if (this.dataSource3[i].id == data.id) {
          this.dataSource3.splice(i, 1, data);
          flag = false;
        }
      }
      if (flag) {
        this.dataSource3.push(data);
      }
      this.loading = false;
    },
    modalFormOk4(data) {
      this.loading = true;
      let flag = true;
      // debugger;
      for (let i = 0; i < this.dataSource4.length; i++) {
        if (this.dataSource4[i].id == data.id) {
          this.dataSource4.splice(i, 1, data);
          flag = false;
        }
      }
      if (flag) {
        this.dataSource4.push(data);
      }
      this.loading = false;
    },
    yzdwChange() {
      this.$set(this.model, 'lxr', undefined);
      // this.cust_lxr = erp_omc_customer_manager_contact,lxr,id;
      this.cust_lxr = 'erp_omc_customer_manager_contact,lxr,id,del_flag=0 and main_id=\'' + this.model.yzdw + '\'';
      // this.$set(this.model, 'lxr', undefined);
      // this.$set(this.model, 'lxfs', undefined);
    },
    lxrChange(val) {
      // debugger
      getAction('/api/erp/omc/customermanager/erpOmcCustomerManagerContact/queryById', { id: val }).then((res) => {
        if (res.success) {
          let data = res.result.records || res.result
          // debugger;
          // this.model.lxdh = data.lxfs;
          this.$set(this.model, 'lxr', val)
          this.$set(this.model, 'lxfs', data.lxfs)
        }
      })
    },
    ...mapGetters(['userInfo']),
    add() {
      this.dataSource = []
      this.dataSource2 = []
      this.dataSource3 = []
      this.dataSource4 = []
      this.modelDefault.lx = 1
      this.sfbg = false;
      this.edit(this.modelDefault);
      this.model.createTime = moment().format('YYYY-MM-DD HH:mm:ss');
      this.model.proposer = this.userInfo().empId;
      this.model.proposerDeptId = this.userInfo().deptId;
      this.showKxxx = true;
      this.generatedFormNumber();
    },
    generatedFormNumber() {
      getAction(this.url.generatedFormNumber, { prefix: 'HT', subSystemCode: '05' }).then(res => {
        if (res.success) {
          this.$set(this.model, 'htbh', res.result)
        }
      })
    },
    add2() {
      this.dataSource = []
      this.dataSource2 = []
      this.dataSource3 = []
      this.dataSource4 = []
      this.modelDefault.lx = 2
      this.sfbg = true
      this.edit(this.modelDefault);
      this.showKxxx = false;
    },
    edit(record) {
      this.$refs.form.resetFields();
      this.model = Object.assign({}, record);
      this.model1 = Object.assign({}, record);
      // 根据ID获取定标结果确认单单号 用于穿透
      if (this.formDisabled && this.model.calibrationId) {
        getAction(this.url.queryCalibrationById, { id: this.model.calibrationId }).then( res => {
          this.$set(this.model, 'calibrationNo', res.result.purchaseBill);
        }).catch(e => {
          console.log(e)
        })
      }
      // 根据ID获取采购申请单单号 用于穿透
      if (this.formDisabled && this.model.purchaseApplyId) {
        getAction(this.url.queryPurchaseApplyById, {id: this.model.purchaseApplyId }).then(res => {

          this.$set(this.model, 'purchaseNo', res.result.purchaseBill);
        }).catch(e => {
          console.log(e)
        })
      }
      //根据ID获取采购申请单单号 用于穿透
      if(this.formDisabled&&this.model.invitationId){
        getAction(this.url.queryInvitationById,{id:this.model.invitationId}).then(res=>{
          this.$set(this.model,'invitationNo',res.result.purchaseBill);
        }).catch(e=>{
          console.log(e)
        })
      }
      if (record.lx == 2) {
        this.sfbg = true
        this.$set(this.validatorRules, 'caId', [{ required: true, message: '请选择合同编号!' }])
        this.$set(this.validatorRules, 'bglx', [{ required: true, message: '请选择变更类型!' }])
        this.$set(this.validatorRules,'sfyz',[{ required: true, message: '请选择是否用印!' }])
      } else {
        this.sfbg = false;
        this.$delete(this.validatorRules, 'caId')
        this.$delete(this.validatorRules, 'bglx')
      }
      if (this.model && this.model.htlx) {
        if (this.model.isCategoryType) {
          this.handleChangeCategory(this.model.isCategoryType)
          if (this.model.provisionType) {
            this.handleChangeProvisionType(this.model.provisionType)
          }
        }
        if (this.model.htlx === '1' || this.model.htlx === 1) {// 收款合同
          // 客户
          this.$refs.itemList4.isFk = true
          // 公司
          this.$refs.itemList3.isFk = false
          this.changeTitle(this.model.htlx)
        } else { // 付款合同
          this.$set(this.validatorRules, 'isCategoryType', [{ required: true, message: '请选择合同是否采购类!' }]);
          // 客户
          this.$refs.itemList4.isFk = false
          // 公司
          this.$refs.itemList3.isFk = true
          this.changeTitle(this.model.htlx)
        }
      } else {// 默认
        // 客户
        this.$refs.itemList4.isFk = false
        // 公司
        this.$refs.itemList3.isFk = true
        this.changeTitle()
      }
      this.$set(this, 'isFkht', this.model.htlx != '1')

      // this.cust_lxr = erp_omc_customer_manager_contact,lxr,id;
      this.cust_lxr = 'erp_omc_customer_manager_contact,lxr,id,del_flag=0 and main_id=\'' + this.model.yzdw + '\'';

      // if (this.model.bchte) {
      //   this.model.bchte = this.model.bchte / 100
      // }
      if (this.model.id) {
        // 收款计划
        getAction(this.url.queryPlanList, { mainId: this.model.id }).then((res) => {
          if (res.success) {
            this.dataSource = res.result || res.result.records
          }
        })

        // 任务信息 20230421 收款合同存在任务，付款合同删除任务
        if(this.model.htlx=='1'){
          getAction(this.url.queryClassList, { mainId: this.model.id }).then((res) => {
            if (res.success) {
              this.dataSource2 = res.result.records || res.result
            }
          })
        }else{
          this.dataSource2=[]
        }

        // 受托方信息
        getAction(this.url.queryTrusteeList, { mainId: this.model.id }).then((res) => {
          if (res.success) {
            this.dataSource3 = res.result.records || res.result
          }
        })

        // 委托方信息
        getAction(this.url.queryEntrustList, { mainId: this.model.id }).then((res) => {
          if (res.success) {
            this.dataSource4 = res.result.records || res.result
          }
        })
        this.showKxxx = this.model.lx == 2 ? this.model.sfbgkxxx == '1' : true
        // this.glhtFlag = this.model.glskht == '1' ? true : false
      }
      this.involveMultipleFlag = record.involveMultiple == 1
      // this.cust_lxr = 'erp_omc_customer_manager_contact,lxr,id';
      // this.cust_lxr = 'erp_omc_customer_manager_contact,lxr,id,del_flag=0 and main_id=\'' + this.model.yzdw + '\'';
      // 服务期限
      if(!!this.model.fwqx&&!!this.model.fwqxEnd){
        this.createTime = []
        this.createTime.push(this.model.fwqx)
        this.createTime.push(this.model.fwqxEnd)
      }else{
        this.createTime = []
      }
      if(this.model.htlx=='1'){
        this.$set(this.validatorRules, 'distributionMethod', [{ required: true, message: '请选择分配方式!' }])
      }else{
        this.$delete(this.validatorRules,'distributionMethod')
      }
      this.glhtFlag = this.model.glskht == '1'
      this.skhtmcRequire(this.model.glskht)
      this.visible = true;
      this[this.otherKey].forEach((val,index) => {
        val.width = this[this.otherKey+'width'][index]
      })
    },
    // 渲染流程表单数据
    showFlowData() {
      if (this.formBpm === true) {
        let params = { id: this.formData.dataId };
        getAction(this.url.queryById, params).then((res) => {
          if (res.success) {
            this.edit(res.result);
          }
        });
      }
    },
    valdateContractMoney() {
      let planSum = 0;
      this.dataSource.forEach(data => {
        planSum += data.je;
      });
      // 迭代11 TASK#3763 2.收付款计划栏金额与合同总金额不对等时不可以发起，需要校验核对收付款计划金额和合同总金额
      if (this.model.bchte.toFixed(2) != planSum.toFixed(2)) {
        message.warning('计划总金额与合同金额不对等!')
        return false;
      }
      // 付款合同的本次合同额应该只是对外的任务的金额，不能校验本次合同额等于所有任务的总额
      if (this.model.htlx === 1 || this.model.htlx === '1') {
        if(this.model.distributionMethod==1){
          let rate = 0
          this.dataSource2.forEach(val => {
            rate += parseFloat(val.htzb)
          })
          if (rate != 100) {
            message.warning('合同占比相加不等于100%，请重新填写')
            return false;
          }
        } else {
          let total = 0
          this.dataSource2.forEach(val => {
            total += parseFloat(val.fphte)
          })
          if (total.toFixed(2) != parseFloat(this.model.bchte).toFixed(2)) {
            message.warning('所有分配金额总计和本次合同额不相等，请重新填写')
            return false;
          }
        }
      }
      return true;
    },
    submitForm() {
      const that = this;
      this.isSubmit = false
      // 触发表单验证
      this.$refs.form.validate(valid => {
        if (valid) {
          // 校验合同金额
          if (!this.valdateContractMoney()) {
            this.$emit('unButtonDisable');
            return;
          }
          // 迭代11 委托方和受托方列表需要校验两个分别必须至少有一条数据 是否为收付款单位有各且仅有一个
          if(!this.validateClientDetailAndTrusteeDetail()){
            this.$emit('unButtonDisable');
            return;
          }
          that.confirmLoading = true;
          let httpurl = '';
          let method = '';
          if (!this.model.id) {
            httpurl += this.url.add;
            method = 'post';
          } else {
            httpurl += this.url.edit;
            method = 'put';
          }
          if (that.model.htlx === 1 || that.model.htlx === '1') {
            if (that.dataSource.length === 0) {
              that.$message.warn('请填写收付款计划');
              that.confirmLoading = false
              that.$emit('unButtonDisable');
              return;
            }
          }
          let model = {};
          Object.assign(model, this.model)
          // if (model.bchte) {
            // this.$set(this.model,"yjhte",yjhte * 100)
          //   model.bchte = model.bchte * 100;
          // }

          // 收付款计划
          model.planList = this.dataSource;
          model.planList.map((value, index) => {
            value.sortOrder = index
            return value
          })
          // for (let i = 0; i < model.planList.length; i++) {
          //   // debugger;
          //   model.planList[i].je = model.planList[i].je * 100
          // }

          model.classList = this.dataSource2;
          model.trusteeList = this.dataSource3;
          model.entrustList = this.dataSource4;
          //迭代11 todo 标题修改
          // debugger;

          httpAction(httpurl, model, method).then((res) => {
            if (res.success) {
              that.$message.success(res.message);
              that.$emit('ok');
              let params = { id: this.formData.dataId };
              getAction(this.url.queryById, params).then((res) => {
                if (res.success) {
                  this.model1 = res.result
                  this.isSubmit = true
                }
              });
            } else {
              that.$message.warning(res.message);
              that.$emit('unButtonDisable');
            }
          }).catch((error) => {
            that.$emit('unButtonDisable');
          }).finally(() => {
            that.confirmLoading = false;
          })
        } else {
          that.$emit('unButtonDisable');
        }
      })
    },
    convertMoney1() {
      let money = this.model.skhte
      this.$set(this.model, 'skhtedx', convertCurrency(money))
    },
    convertMoney2() {
      let money = this.model.bchte
      this.$set(this.model, 'bchtedx', convertCurrency(money))
      this.getMoney()
    },
    // 切换项目 任务信息  数据占比信息改变
    changeMoney(){
      if (this.model.bchte&&this.dataSource2.length) {
        this.dataSource2.forEach((item) => {
          if(this.model.distributionMethod==1){
            // 按比例：更改预计合同额，占比不变、对应的分配合同额实时变化
            // item.fphte = parseFloat(item.htzb*0.01*parseFloat(this.model.bchte)).toFixed(2)
            let amount = this.model.bchte * item.htzb / 100
            item.fphte = Math.round((amount + Number.EPSILON) * 100) / 100
          } else {
            // 按金额：更改预计合同额，分配合同额不变、对应的占比实时变化
            let rate = item.fphte / this.model.bchte * 100
            item.htzb = Math.round((rate + Number.EPSILON) * 100) / 100;
            // item.htzb = parseFloat(parseFloat(item.fphte) / parseFloat(this.model.bchte)*100).toFixed(2)
          }
        })
      }
    },
    getMoney(){
      this.dataSource2.forEach((item, index) => {
       // item.finalId = item.id
        if (this.model.bchte) {
          if(this.model.distributionMethod==1){
            // 按比例：更改预计合同额，占比不变、对应的分配合同额实时变化
            // item.fphte = parseFloat(item.htzb*0.01*parseFloat(this.model.bchte)).toFixed(2)
            let amount = this.model.bchte * item.htzb / 100
            item.fphte = Math.round((amount + Number.EPSILON) * 100) / 100
          } else {
            // 按金额：更改预计合同额，分配合同额不变、对应的占比实时变化
            let rate = item.fphte / this.model.bchte * 100
            item.htzb = Math.round((rate + Number.EPSILON) * 100) / 100;
            // item.htzb = parseFloat(parseFloat(item.fphte) / parseFloat(this.model.bchte)*100).toFixed(2)
          }
        } else {
          if(this.model.distributionMethod==1){
            // 按比例：更改预计合同额，占比不变、对应的分配合同额实时变化
            item.fphte = 0
          } else {
            // 按金额：更改预计合同额，分配合同额不变、对应的占比实时变化
            item.htzb = 0
          }
        }
      })
    },
    handleJvxeChange(value,rowIndex,key){
      if (this.model.bchte) {
        if (key == 'fphte') {
          let rate = value / this.model.bchte * 100
          this.dataSource2[rowIndex].htzb = Math.round((rate + Number.EPSILON) * 100) / 100;
        } else {
          let amount = this.model.bchte * value / 100
          this.dataSource2[rowIndex].fphte = Math.round((amount + Number.EPSILON) * 100) / 100;
        }
      } else {
        this.dataSource2[rowIndex].htzb = 0
        this.dataSource2[rowIndex].fphte = 0
      }
    },
    xmmcChange(val) {
      getAction('/api/erp/omc/project/erpOmcProject/queryById', { id: val }).then((res) => {
        if (res.success) {
          let data = res.result.records || res.result
          // debugger;
          // this.model.lxdh = data.lxfs;
          this.$set(this.model, 'calibrationId', null) // 定标结果确认单
          this.$set(this.model, 'xmbh', data.projectNo) // 项目编号
          this.$set(this.model, 'jytd', data.teamName) // 经营团队
          this.$set(this.model, 'businessCompanyId', data.businessCompanyId) // 经营团队
          this.$set(this.model, 'yjgsnd', data.year) // 业绩归属年度
          this.$set(this.model, 'qddw', data.signUnit) // 签定单位
          this.$set(this.model, 'xmcjr', data.undertaker) // 项目承接人
          this.$set(this.model, 'yzdw', data.ownerUnit) // 业主单位
          this.$set(this.model, 'lxr', data.contacts) // 联系人
          this.$set(this.model, 'lxfs', data.contactTel) // 联系方式
          this.cust_lxr = 'erp_omc_customer_manager_contact,lxr,id,del_flag=0 and main_id=\'' + this.model.yzdw + '\'';
          //收款合同查询任务信息
          if(this.model.htlx=='1'){
            // 任务信息
            getAction(this.url.queryClassList2, { pageNo:1,pageSize: 999,projectId: data.id }).then((res) => {
              this.dataSource2 = []
              if (res.success) {
                let data = res.result.records || res.result
                for (let i = 0; i < data.length; i++) {
                  let d = {
                    'ywfl': data[i].categoryCode,
                    'ywmc': data[i].categoryName,
                    'htzb': data[i].contractRate,
                    'fphte': data[i].contractAmount,
                    'sctd': data[i].productTeam,
                    'sctd_dictText': data[i].productTeam_dictText,
                    'tdfzr': data[i].teamLeader,
                    'tdfzr_dictText': data[i].teamLeader_dictText,
                    'projectTaskId': data[i].id
                  };
                  let index = this.dataSource2.findIndex(item => item.ywfl == d.ywfl)
                  if (index > -1) {
                    this.dataSource2.splice(index, 1, d)
                  } else {
                    this.dataSource2.push(d);
                  }
                }
                this.changeMoney()
              }
            })
            this.$set(this.model,'distributionMethod',data.distributionMethod || '')
        }else{
            this.dataSource2 = []
          }
          var params = {
            preProjectId: data.id,
            feeCategory: '2',
            bpmStatus: '3'
          }
          // 查看项目保证金
          getAction(this.url.queryProjectDeposit, params).then((res) => {
            if (res.success) {
              let data = res.result.records || res.result
              this.$set(this.model, 'bail', data.remittanceAmount)
            }
          })
        }
      })
    },
    handleChangeCategory(val) {
      if (val == '1') {
        this.$set(this.validatorRules, 'provisionType', [{ required: true, message: '请选择采购类型!' }]);
      } else {
        this.$set(this.model, 'provisionType', null);
        this.$delete(this.validatorRules, 'provisionType');
        this.$set(this.model, 'purchaseApplyId', null);
        this.$delete(this.validatorRules, 'purchaseApplyId');
        this.$set(this.model, 'calibrationId', null);
        this.$delete(this.validatorRules, 'calibrationId');
        this.$set(this.model, 'invitationId', null);
        this.$delete(this.validatorRules, 'invitationId');
      }
    },
    handleChangeProvisionType(val) {
      if (val == '1') {
        this.$set(this.validatorRules, 'calibrationId', [{ required: true, message: '请选择定标结果确认单!' }]);
        //清除采购申请单数据及校验
        this.$set(this.model, 'purchaseApplyId', null);
        this.$delete(this.validatorRules, 'purchaseApplyId');
        //清除招标采购申请单数据及校验
        this.$set(this.model, 'invitationId', null);
        this.$delete(this.validatorRules, 'invitationId');

      } else if (val == '2') {
        this.$set(this.validatorRules, 'purchaseApplyId', [{ required: true, message: '请选择采购申请单!' }]);
        //清除定标结果确认单数据及校验
        this.$set(this.model, 'calibrationId', null);
        this.$delete(this.validatorRules, 'calibrationId');

        //清除招标采购申请单数据及校验
        this.$set(this.model, 'invitationId', null);
        this.$delete(this.validatorRules, 'invitationId');
      }else if(val == '3'){
        this.$set(this.validatorRules, 'invitationId', [{ required: true, message: '请选择采购申请单!' }]);
        //清除采购申请单数据及校验
        this.$set(this.model, 'purchaseApplyId', null);
        this.$delete(this.validatorRules, 'purchaseApplyId');

        //清除请选择定标结果确认单数据及校验
        this.$set(this.model, 'calibrationId', null);
        this.$delete(this.validatorRules, 'calibrationId');
      }else {
        //清除采购申请单数据及校验
        this.$set(this.model, 'purchaseApplyId', null);
        this.$delete(this.validatorRules, 'purchaseApplyId');
        //清除招标采购申请单数据及校验
        this.$set(this.model, 'invitationId', null);
        this.$delete(this.validatorRules, 'invitationId');
        //清除定标结果确认单数据及校验
        this.$set(this.model, 'calibrationId', null);
        this.$delete(this.validatorRules, 'calibrationId');
      }
    },
    htlxChange(val) {
      this.$set(this.model, 'htlx', val)
      if (val) {
        let url;
        if (val === '1') {
          // 合同类型为收款合同，需要做特殊处理
          // updated  by wuzx at 2021/12/28 调整为立项底表查询,不带bpmStatus
          // 修改前:  url = '/api/erp/omc/project/erpOmcProjectApply/list2?bpmStatus=3&isSkht=true";
          // 修改后:
          url = '/api/erp/omc/project/erpOmcProject/list2?isSkht=true';
          this.$set(this.model, 'glskht', '0')
          this.glhtFlag = false;
          this.skhtmcRequire(this.model.glskht)
          // 将受托方子modal中的是否显示付款改为false
          this.$refs.itemList4.isFk = false
          this.$refs.itemList3.isFk = true
          // this.$set(this.model,'distributionMethod',data.distributionMethod || '')
          this.changeTitle(val)
        } else {
          // 合同类型为收款合同，需要做特殊处理
          // updated by wuzx at 2021/12/28 调整为立项底表查询,不带bpmStatus
          // 修改前: url = '/api/erp/omc/project/erpOmcProjectApply/list2?bpmStatus=3&isSkht=false";
          // 修改后:
          url = '/api/erp/omc/project/erpOmcProject/list2?isSkht=false';
          // 将受托方子modal中的是否显示付款改为true
          this.$refs.itemList4.isFk = true
          this.$refs.itemList3.isFk = false
          this.changeTitle(val)
        }
        this.$set(this, 'isFkht', val !== '1');
        this.$refs.projectModel.loadData(url);
      }
      // 切换合同类型时清空委托方、受托方信息
      this.dataSource4 = [];
      this.dataSource3 = [];
    },
    glskhtChange(val) {
      this.$set(this.model, 'glskht', val)
      if (val) {
        this.skhtmcRequire(val)
        if (val === '1') {
          this.glhtFlag = true;
        } else {
          this.glhtFlag = false;
        }
      }
    },
    skhtmcRequire(val){
      if (val == '1') {
        this.$set(this.validatorRules, 'skhtmc', [{ required: true, message: '请选择收款合同名称!' }]);
      } else {
        this.$set(this.model, 'skhtmc', '');
        this.$set(this.model, 'skhte', '');
        this.$set(this.model, 'skhtedx', '');
        this.$delete(this.validatorRules, 'skhtmc');
      }
    },
    // changeTitle(args) {
    //    if (args === 1) {
    //      this.firstTitle = '受托方信息'
    //      this.secondTitle = '委托方信息'
    //    } else {
    //      this.firstTitle = '委托方信息'
    //      this.secondTitle = '受托方信息'
    //    }
    // },
    changeTitle(args) {
      if (args == '1') {// 收款合同类型时
        this.firstTitle = '委托方(合同甲方)信息'
        this.secondTitle = '受托方(合同乙方)信息'
        // 修改列表表头
        this.$set(this,'columns4',[
          {
            title: '名称',
            align: 'center',
            dataIndex: 'khdaId',
            customRender: (text) => {
              if (!text) {
                return ''
              } else {
                return filterMultiDictText(this.dictOptions['khda'], text + '')
              }
            }
          },
          {
            title: '是否为付款单位',
            align: 'center',
            dataIndex: 'isFk',
            customRender: (text) => {
              if (!text) {
                return ''
              } else {
                return filterDictTextByCache('yes_no',text)
              }
            }
          },
          {
            title: '对方是否电子签章',
            align: 'center',
            dataIndex: 'isSignSeal',
            customRender: (text) => {
              if (!text) {
                return ''
              } else {
                return filterDictTextByCache('yes_no', text)
              }
            }
          },
          {
            title: '对方盖章人',
            align: 'center',
            dataIndex: 'psnName'
          },
          {
            title: '联系方式',
            align: 'center',
            dataIndex: 'psnMobile'
          },
          {
            title: '操作',
            dataIndex: 'action',
            align: 'center',
            scopedSlots: {
              filterDropdown: 'filterDropdown',
              filterIcon: 'filterIcon',
              customRender: 'action'
            }
          }
        ])
        this.$set(this,'columns3',[
          {
            title: '名称',
            align: 'center',
            dataIndex: 'gsdaId',
            customRender: (text) => {
              if (!text) {
                return ''
              } else {
                return filterMultiDictText(this.dictOptions['gsda'], text + '')
              }
            }
          },
          {
            title: '是否为收款单位',
            align: 'center',
            dataIndex: 'isSk',
            customRender: (text) => {
              if (!text) {
                return ''
              } else {
                return filterDictTextByCache('yes_no',text)
              }
            }
          },
          {
            title: '我方经办人',
            align: 'center',
            dataIndex: 'psnName'
          },
          {
            title: '联系方式',
            align: 'center',
            dataIndex: 'psnMobile'
          },
          {
            title: '操作',
            dataIndex: 'action',
            align: 'center',
            scopedSlots: {
              filterDropdown: 'filterDropdown',
              filterIcon: 'filterIcon',
              customRender: 'action'
            }
          }
        ])
      } else {// 付款合同类型时
        this.firstTitle = '受托方(合同乙方)信息'
        this.secondTitle = '委托方(合同甲方)信息'
        // 修改列表表头
        this.$set(this,'columns4',[
          {
            title: '名称',
            align: 'center',
            dataIndex: 'khdaId',
            customRender: (text) => {
              if (!text) {
                return ''
              } else {
                return filterMultiDictText(this.dictOptions['khda'], text + '')
              }
            }
          },
          {
            title: '是否为收款单位',
            align: 'center',
            dataIndex: 'isSk',
            customRender: (text) => {
              if (!text) {
                return ''
              } else {
                return filterDictTextByCache('yes_no',text)
              }
            }
          },
          {
            title: '对方是否电子签章',
            align: 'center',
            dataIndex: 'isSignSeal',
            customRender: (text) => {
              if (!text) {
                return ''
              } else {
                return filterDictTextByCache('yes_no', text)
              }
            }
          },
          {
            title: '对方盖章人',
            align: 'center',
            dataIndex: 'psnName'
          },
          {
            title: '联系方式',
            align: 'center',
            dataIndex: 'psnMobile'
          },
          {
            title: '操作',
            dataIndex: 'action',
            align: 'center',
            scopedSlots: {
              filterDropdown: 'filterDropdown',
              filterIcon: 'filterIcon',
              customRender: 'action'
            }
          }
        ])
        this.$set(this,'columns3',[
          {
            title: '名称',
            align: 'center',
            dataIndex: 'gsdaId',
            customRender: (text) => {
              if (!text) {
                return ''
              } else {
                return filterMultiDictText(this.dictOptions['gsda'], text + '')
              }
            }
          },
          {
            title: '是否为付款单位',
            align: 'center',
            dataIndex: 'isFk',
            customRender: (text) => {
              if (!text) {
                return ''
              } else {
                return filterDictTextByCache('yes_no',text)
              }
            }
          },
          {
              title: '我方经办人',
              align: 'center',
              dataIndex: 'psnName'
            },
            {
              title: '联系方式',
              align: 'center',
              dataIndex: 'psnMobile'
            },
          {
            title: '操作',
            dataIndex: 'action',
            align: 'center',
            scopedSlots: {
              filterDropdown: 'filterDropdown',
              filterIcon: 'filterIcon',
              customRender: 'action'
            }
          }
        ])
      }
    },
    htbhChange(val) {
      getAction('/api/erp/omc/contractmanager/erpOmcContractManagerFinal/queryById', { id: val }).then((res) => {
        if (res.success) {
          let data = res.result.records || res.result
          // debugger;
          this.$set(this.model, 'caId', val)
          this.$set(this.model, 'htmc', data.htmc) // 合同名称
          this.$set(this.model, 'htlx', data.htlx) // 合同类型
          this.$set(this.model, 'xmmc', data.xmmc) // 项目名称
          this.$set(this.model, 'jytd', data.jytd) // 经营团队
          this.$set(this.model, 'businessCompanyId', data.businessCompanyId) // 经营团队
          this.$set(this.model, 'yjgsnd', data.yjgsnd)// 业绩归属年度
          this.$set(this.model, 'qddw', data.qddw) // 签订单位
          this.$set(this.model, 'xmcjr', data.htmc) // 项目承认人
          this.$set(this.model, 'yzdw', data.yzdw)// 业主单位
          this.$set(this.model, 'lxr', data.lxr)// 联系人
          this.$set(this.model, 'lxfs', data.lxfs) // 联系方式
          this.$set(this.model, 'qdrq', data.qdrq)// 签订日期
          this.$set(this.model, 'sfyz', data.sfyz)// 是否用印
          this.$set(this.model, 'yzlx', data.yzlx) // 印章类型
          this.$set(this.model, 'yyfs', data.yyfs)// 用印份数
          this.$set(this.model, 'glskht', data.glskht) // 关联收款合同
          this.skhtmcRequire(data.glskht)
          this.$set(this.model, 'skhtmc', data.skhtmc) // 收款合同名称
          this.$set(this.model, 'jf', data.qddw)// 甲方
          /*  this.$set(this.model, 'jf', data.yzdw) // 甲方
           this.$set(this.model, 'yf', data.qddw) // 已方 */
          this.$set(this.model, 'skhte', data.skhte)// 收款合同额
          this.$set(this.model, 'skhtedx', data.skhtedx)// 收款合同额大写
          this.$set(this.model, 'isCategoryType', data.isCategoryType) // 是否采购类
          this.$set(this.model, 'provisionType', data.provisionType) // 采购类型
          this.$set(this.model, 'calibrationId', data.calibrationId) // 定标结果确认单
          this.$set(this.model, 'purchaseApplyId', data.purchaseApplyId) // 采购申请单
          this.handleChangeCategory(data.isCategoryType)
          if (data.isCategoryType == '1') {
            this.handleChangeProvisionType(data.provisionType)
          }
          let bchte = data.bchte;
          // if (data.bchte) {
          //   bchte = data.bchte / 100
          // }

          this.$set(this.model, 'bchte', bchte)
          this.$set(this.model, 'bchtedx', data.bchtedx)
          this.$set(this.model, 'fwqx', data.fwqx)
          this.$set(this.model, 'fwqxEnd', data.fwqxEnd)
          // 服务期限
          if(!!this.model.fwqx&&!!this.model.fwqxEnd){
            this.createTime = []
            this.createTime.push(this.model.fwqx)
            this.createTime.push(this.model.fwqxEnd)
          }else{
            this.createTime = []
          }
          this.$set(this.model, 'bz', data.bz) // 备注
          this.$set(this.model, 'yjxx', data.yjxx) // 邮寄信息
          this.$set(this.model, 'xgfj', data.xgfj) // 相关附件
          this.$set(this.model, 'htbh', data.htbh) // 合同编号
          this.$set(this.model, 'xmbh', data.xmbh) // 合同编号

          this.$set(this.model, 'bglx', data.bglx)
          this.$set(this.model, 'sfbgkxx', data.sfbgkxx)
          this.$set(this.model, 'proposer', data.proposer)
          this.$set(this.model, 'proposerDeptId', data.proposerDeptId)
          this.$set(this, 'isFkht', data.htlx != '1')
          this.$set(this.model, 'masterCopy', data.masterCopy) // 合同原件
          this.yzdwChange();

          // 收款计划
          getAction('/api/erp/omc/contractmanager/erpOmcContractManagerPlanFinal/listAll', { mainId: val }).then((res) => {
            if (res.success) {
              this.dataSource = res.result.records || res.result
              if (this.dataSource.length > 0) {
                this.dataSource.forEach((item, index) => {
                  item.finalId = item.id
                })
              }
            }
          })

          // 任务信息
          getAction('/api/erp/omc/contractmanager/erpOmcContractManagerClassFinal/listAll', { mainId: val }).then((res) => {
            if (res.success) {
              this.dataSource2 = res.result.records || res.result
              this.dataSource2.forEach((item, index) => {
                item.finalId = item.id
              })
              this.getMoney()
            }
          })

          // 受托方信息
          getAction('/api/erp/omc/contractmanager/erpOmcContractManagerTrusteeFinal/listAll', { mainId: val }).then((res) => {
            if (res.success) {
              this.dataSource3 = res.result.records || res.result
              this.dataSource3.forEach((item, index) => {
                item.finalId = item.id
              })
            }
          })

          // 委托方信息
          getAction('/api/erp/omc/contractmanager/erpOmcContractManagerEntrustFinal/listAll', { mainId: val }).then((res) => {
            if (res.success) {
              this.dataSource4 = res.result.records || res.result
              this.dataSource4.forEach((item, index) => {
                item.finalId = item.id
              })
            }
          })
        }
      })
    },
    skhtBack (item) {
      //this.$set(this.model, 'skhtmc', item[0].htmc)
      this.$set(this.model, 'jf', item[0].qddw)
      this.$set(this.model, 'skhte', item[0].bchte)
      this.$set(this.model, 'skhtedx', item[0].bchtedx)
    },
    handleValueChange(event){
      const { rowIndex, columnIndex,value } = event
      if(this.model.bchte){
        if(columnIndex == 3){
          let amount = this.model.bchte * value / 100
          this.dataSource2[rowIndex].fphte = Math.round((amount + Number.EPSILON) * 100) / 100;
        } else if (columnIndex == 4){
          let rate = value / this.model.bchte * 100
          this.dataSource2[rowIndex].htzb = Math.round((rate + Number.EPSILON) * 100) / 100;
        }
      }
    },
    handleChangeSfbgkxxx(val) {
      this.$set(this.model, 'sfbgkxxx', val);
      this.$set(this, 'showKxxx', val == '1');
    },
    // 服务期限开始时间 结束时间
    createTimeChange(date, dateString) {
      this.$set(this.model, 'fwqx', dateString[0] + ' 00:00:00')
      this.$set(this.model, 'fwqxEnd', dateString[1] + ' 23:59:59')
    },
    // 校验委托方和受托方子表数据合法性 委托方和受托方列表需要校验两个分别必须至少有一条数据 是否为收付款单位有各且仅有一个
    validateClientDetailAndTrusteeDetail(){
      if(this.model.htlx=='1'){ // 收款合同 dataSource4 为收款
        // 委托方(合同乙方)信息校验
        if(!!this.dataSource4&&this.dataSource4.length==0){
          message.warning("请填写委托方信息!")
          return false;
        }else{
          let hasFkList = this.dataSource4.filter(item => item.isFk == '1');
          if (hasFkList.length <= 0) {
            message.warning('委托方必须有一个付款单位!')
            return false;
          }
          // 判断当选择是否用印为是且用印类型是电子签章的时候判断是否填写了盖章人信息和联系方式信息
          // let psnName = this.dataSource4.filter(item => item.psnName);
          // let psnMobile = this.dataSource4.filter(item => item.psnMobile);
          if (this.isShowSeal && this.model.signSealWay == 'online') {
            // 当主表选择了电子签章
            for (var i = 0; i < this.dataSource4.length; i++) {
              if (this.dataSource4[i].isSignSeal && this.dataSource4[i].isSignSeal == 1) {
                if (!this.dataSource4[i].psnName || !this.dataSource4[i].psnMobile) {
                  message.warning('请填写委托方联系人和联系方式!')
                  return
                }
              }
            }
          }
        }
        // 受托方(合同甲方)信息
        if(!!this.dataSource3&&this.dataSource3.length==0){
          message.warning("请填写受托方信息!")
          return false;
        }else{
          let hasSkList = this.dataSource3.filter(item=>item.isSk=='1');
          if(hasSkList.length!=1){
            message.warning("受托方有且仅有一个是收款单位!")
            return false;
          }
          // 判断当选择是否用印为是且用印类型是电子签章的时候判断是否填写了盖章人信息和联系方式信息
          let psnName = this.dataSource3.filter(item => !item.psnName);
          let psnMobile = this.dataSource3.filter(item => !item.psnMobile);
          if (this.isShowSeal && this.model.signSealWay == 'online') {
            // 当主表选择了电子签章
            if (psnName.length || psnMobile.length) {
              message.warning('请填写受托方联系人和联系方式!')
            return false;
            }
          }
        }
        return true;
      }else{// 付款合同 dataSource4 客户为受托方(收款)
        // 受托方(合同乙方)信息校验
        if(!!this.dataSource4&&this.dataSource4.length==0){
          message.warning("请填写受托方信息!");
          return false;
        }else{
          let hasSkList = this.dataSource4.filter(item=>item.isSk=='1');
          if(hasSkList.length!=1) {
            message.warning("受托方有且仅有一个是收款单位!")
            return false;
          }
          // 判断当选择是否用印为是且用印类型是电子签章的时候判断是否填写了盖章人信息和联系方式信息
          // let psnName = this.dataSource4.filter(item => item.psnName);
          // let psnMobile = this.dataSource4.filter(item => item.psnMobile);
          if (this.isShowSeal && this.model.signSealWay == 'online') {
            // 当主表选择了电子签章
            for (var i = 0; i < this.dataSource4.length; i++) {
              if (this.dataSource4[i].isSignSeal && this.dataSource4[i].isSignSeal == 1) {
                if (!this.dataSource4[i].psnName || !this.dataSource4[i].psnMobile) {
                  message.warning('请填写受托方联系人和联系方式!')
                  return
                }
              }
            }
          }
        }
        // 付款合同 dataSource3 公司 为委托方(合同甲方) 付款
        if(!!this.dataSource3&&this.dataSource3.length==0) {
          message.warning("请填写委托方信息!");
          return false;
        }else{
          let hasFkList = this.dataSource3.filter(item=>item.isFk=='1');
          if(hasFkList.length!=1){
            message.warning("委托方有且仅有一个是付款单位!")
            return false;
          }
          // 判断当选择是否用印为是且用印类型是电子签章的时候判断是否填写了盖章人信息和联系方式信息
          let psnName = this.dataSource3.filter(item => !item.psnName);
          let psnMobile = this.dataSource3.filter(item => !item.psnMobile);
          if (this.isShowSeal && this.model.signSealWay == 'online') {
            // 当主表选择了电子签章
            if (psnName.length || psnMobile.length) {
              message.warning('请填写委托方联系人和联系方式!')
            return false;
            }
          }
        }
        return true;
      }
    },

    // 点击打印
    onPrint () {
      let print = new Print({
        el: '#payContractmanageContent1',
        popTitle: '项目付款合同申请详情 · 禾美环保',
        endCallback() {

        }
      })
    }
  }
}
</script>
<style>
  @import "../../../../../utils/print.css";
</style>